package com.jh.paymentchannel.util;

import java.lang.reflect.Field;
import java.util.TreeMap;

public class DataUtils {

    public static TreeMap<String ,Object> objToMap(Object obj){
        Field[] fields = obj.getClass().getDeclaredFields();
        TreeMap<String, Object> map = new TreeMap<>();
        try {
            for(Field field: fields){
                field.setAccessible(true);
                String name = field.getName();
                map.put(name, field.get(obj));
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return map;
    }

}
